package com.kexio.pay.entity;

import java.math.BigDecimal;
import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.kexio.common.entity.BaseEntity;

/**
 * 支付订单
 * 
 * @author Kexio Team
 * @since 1.0.0
 */
@TableName("pay_order")
public class PaymentOrder extends BaseEntity {
    
    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;
    
    /**
     * 订单号 (系统生成)
     */
    @TableField("order_no")
    private String orderNo;
    
    /**
     * 业务类型 (MEMBERSHIP, PRODUCT, SERVICE等)
     */
    @TableField("business_type")
    private String businessType;
    
    /**
     * 业务ID (关联业务订单ID)
     */
    @TableField("business_id")
    private String businessId;
    
    /**
     * 用户ID
     */
    @TableField("user_id")
    private String userId;
    
    /**
     * 支付金额
     */
    @TableField("amount")
    private BigDecimal amount;
    
    /**
     * 订单标题
     */
    @TableField("subject")
    private String subject;
    
    /**
     * 订单描述
     */
    @TableField("body")
    private String body;
    
    /**
     * 支付方式
     */
    @TableField("payment_method")
    private String paymentMethod;
    
    /**
     * 支付场景
     */
    @TableField("payment_scene")
    private String paymentScene;
    
    /**
     * 支付状态
     */
    @TableField("status")
    private String status;
    
    /**
     * 第三方订单号
     */
    @TableField("third_party_order_no")
    private String thirdPartyOrderNo;
    
    /**
     * 第三方交易号 (支付成功后的流水号)
     */
    @TableField("third_party_trade_no")
    private String thirdPartyTradeNo;
    
    /**
     * 客户端IP
     */
    @TableField("client_ip")
    private String clientIp;
    
    /**
     * 用户代理
     */
    @TableField("user_agent")
    private String userAgent;
    
    /**
     * 过期时间
     */
    @TableField("expire_time")
    private LocalDateTime expireTime;
    
    /**
     * 支付成功时间
     */
    @TableField("success_time")
    private LocalDateTime successTime;
    
    /**
     * 关闭时间
     */
    @TableField("close_time")
    private LocalDateTime closeTime;
    
    /**
     * 异步通知地址
     */
    @TableField("notify_url")
    private String notifyUrl;
    
    /**
     * 同步跳转地址
     */
    @TableField("return_url")
    private String returnUrl;
    
    /**
     * 错误码
     */
    @TableField("error_code")
    private String errorCode;
    
    /**
     * 错误信息
     */
    @TableField("error_message")
    private String errorMessage;
    
    /**
     * 扩展信息 (JSON格式)
     */
    @TableField("extra_data")
    private String extraData;
    
    /**
     * 通知次数
     */
    @TableField("notify_count")
    private Integer notifyCount;
    
    /**
     * 最后通知时间
     */
    @TableField("last_notify_time")
    private LocalDateTime lastNotifyTime;
    
    // Constructors
    public PaymentOrder() {}
    
    public PaymentOrder(String orderNo, String businessType, String businessId, String userId, 
                       BigDecimal amount, String subject, String paymentMethod) {
        this.orderNo = orderNo;
        this.businessType = businessType;
        this.businessId = businessId;
        this.userId = userId;
        this.amount = amount;
        this.subject = subject;
        this.paymentMethod = paymentMethod;
        this.status = "PENDING";
        this.notifyCount = 0;
    }
    
    // Getters and Setters
    public String getId() { return id; }
    public void setId(String id) { this.id = id; }
    
    public String getOrderNo() { return orderNo; }
    public void setOrderNo(String orderNo) { this.orderNo = orderNo; }
    
    public String getBusinessType() { return businessType; }
    public void setBusinessType(String businessType) { this.businessType = businessType; }
    
    public String getBusinessId() { return businessId; }
    public void setBusinessId(String businessId) { this.businessId = businessId; }
    
    public String getUserId() { return userId; }
    public void setUserId(String userId) { this.userId = userId; }
    
    public BigDecimal getAmount() { return amount; }
    public void setAmount(BigDecimal amount) { this.amount = amount; }
    
    public String getSubject() { return subject; }
    public void setSubject(String subject) { this.subject = subject; }
    
    public String getBody() { return body; }
    public void setBody(String body) { this.body = body; }
    
    public String getPaymentMethod() { return paymentMethod; }
    public void setPaymentMethod(String paymentMethod) { this.paymentMethod = paymentMethod; }
    
    public String getPaymentScene() { return paymentScene; }
    public void setPaymentScene(String paymentScene) { this.paymentScene = paymentScene; }
    
    public String getStatus() { return status; }
    public void setStatus(String status) { this.status = status; }
    
    public String getThirdPartyOrderNo() { return thirdPartyOrderNo; }
    public void setThirdPartyOrderNo(String thirdPartyOrderNo) { this.thirdPartyOrderNo = thirdPartyOrderNo; }
    
    public String getThirdPartyTradeNo() { return thirdPartyTradeNo; }
    public void setThirdPartyTradeNo(String thirdPartyTradeNo) { this.thirdPartyTradeNo = thirdPartyTradeNo; }
    
    public String getClientIp() { return clientIp; }
    public void setClientIp(String clientIp) { this.clientIp = clientIp; }
    
    public String getUserAgent() { return userAgent; }
    public void setUserAgent(String userAgent) { this.userAgent = userAgent; }
    
    public LocalDateTime getExpireTime() { return expireTime; }
    public void setExpireTime(LocalDateTime expireTime) { this.expireTime = expireTime; }
    
    public LocalDateTime getSuccessTime() { return successTime; }
    public void setSuccessTime(LocalDateTime successTime) { this.successTime = successTime; }
    
    public LocalDateTime getCloseTime() { return closeTime; }
    public void setCloseTime(LocalDateTime closeTime) { this.closeTime = closeTime; }
    
    public String getNotifyUrl() { return notifyUrl; }
    public void setNotifyUrl(String notifyUrl) { this.notifyUrl = notifyUrl; }
    
    public String getReturnUrl() { return returnUrl; }
    public void setReturnUrl(String returnUrl) { this.returnUrl = returnUrl; }
    
    public String getErrorCode() { return errorCode; }
    public void setErrorCode(String errorCode) { this.errorCode = errorCode; }
    
    public String getErrorMessage() { return errorMessage; }
    public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; }
    
    public String getExtraData() { return extraData; }
    public void setExtraData(String extraData) { this.extraData = extraData; }
    
    public Integer getNotifyCount() { return notifyCount; }
    public void setNotifyCount(Integer notifyCount) { this.notifyCount = notifyCount; }
    
    public LocalDateTime getLastNotifyTime() { return lastNotifyTime; }
    public void setLastNotifyTime(LocalDateTime lastNotifyTime) { this.lastNotifyTime = lastNotifyTime; }
}
